#####################################################################
# File:         __init__.py
# Library:      KnowledgeEngine.Elements
#
# Copyright:    Copyright (c) 2002, Faulker Technologies.
# Author:       Brian Oliver
#
# Description:  This file initialises the KnowledgeEngine Elements
#               Package, and all sub packages containing Elements.
#####################################################################

#####################################################################
## Knowledge Engine Library Imports
# (none - done automatically. see below)

#####################################################################
## Zope Library Imports
from App.FindHomes import ppath

#####################################################################
## Python Library Imports
import os
    
#####################################################################    
## Import the KnowledgeEngine Elements
##
## Each KnowledgeEngine Element type resides in an independant package
## (named after the element type) within the Elements folder
## in the KnowledgeEngine Zope Product
##
## By individually importing each Element type, they have a chance of
## performing their own initialisation, including appropriately
## registering themselves as part of the KnowledgeEngine product.

# The path to the KnowledgeEngine Element Packages
ELEMENTS_PATH = ppath[0] + os.sep + "KnowledgeEngine" + os.sep + "Elements"

# Dynamically import each of the defined Element packages in the ELEMENTS_PATH
for element in [file for file in os.listdir(ELEMENTS_PATH) if os.path.isdir(ELEMENTS_PATH + os.sep + file)]:

    # Import the current element (if it doesn't contain a .)
    if element.find(".") < 0:
        print "[KnowledgeEngine] Registering Element: " + element
    
        exec "from Products.KnowledgeEngine.Elements." + element + " import *"

#####################################################################    
